package com.lg.thread;
// YieldTest.java的源码
class ThreadABC extends Thread{
    public ThreadABC(String name){ 
        super(name); 
    } 
    public synchronized void run(){ 
        for(int i=0; i <10; i++){ 
            System.out.printf("%s [%d]:%d\n", this.getName(), this.getPriority(), i); 
            // i整除4时，调用yield
            if (i%4 == 0)
                Thread.yield();
        } 
    } 
} 

public class YieldTest{ 
    public static void main(String[] args){ 
    	ThreadABC t1 = new ThreadABC("t1"); 
    	ThreadABC t2 = new ThreadABC("t2"); 
        t1.start(); 
        t2.start();
    } 
}